package net.openvision.music.composition.rules;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

import net.openvision.music.composition.Element;
import net.openvision.music.composition.ElementClass;
import net.openvision.music.composition.ElementValue;
import net.openvision.util.Constraint;

public class ElementSet extends HashSet<ElementClass> {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 7793207392705152699L;

	public Collection<Element> match(Element uncomplete, Constraint<ElementValue> constraint) {
		Collection<Element> result = new ArrayList<Element>();
		for (ElementClass e:this) {
			if (e.contains(uncomplete.getValue()))
				for (ElementValue ev:e.complete(uncomplete.getValue(), constraint)) {
					result.add(uncomplete.setValue(ev));
				}
		}
		return result;
	}
}
